
root=Node()
axes = Node(root)
axes.Load("axes.osg")
axes.SetScale(10,10,10)

pic1=Node(root)
pic1.Load("borgia1.osg")
pic2=Node(root)
pic2.Load("borgia2.osg")
pic3=Node(root)
pic3.Load("borgia3.osg")
pic3.SetPosition(157.696, -1, 101.499)

pic1.Show(False)
pic3.Show(False)

m = Morph(root)
m.Load("cina.osg",  "skin_hi:FaceGen" )
m.AddTarget("cina_ExpressionSmileOpen.obj",     "skin_hi:FaceGen" )
m.AddTarget("cina_ModifierBlinkLeft.obj",       "skin_hi:FaceGen" )
m.AddTarget("cina_ExpressionFear.obj",          "skin_hi:FaceGen" )
m.AddTarget("cina_Corrector.obj",               "objskin_hi" )
m.SetTargetWeight(3,1)
#m.SetScale(Vec(0.25, 0.25, 0.25))
#m.SetRotation(109.771,-0.529815, 0.529414, -0.662583)
#m.SetPosition(167.385, 21.1698, 86.5466)
#m.SetScale(Vec(0.25,0.00001,0.25))

m.SetPosition(161.826, 1, 105.132)
m.SetRotation(112.403, 0.525308, -0.525308, -0.669404)
m.SetScale(Vec(0.25, 0.25, 0.25))
m.RotateY(55)
#m.SetScale(Vec(0.25,0.00001,0.25))

ha = Node(m)
ha.Load("hair.osg")

DemoName = """
Tecniche per la Ricostruzione di volti

      dal Ritratto al modello 3D:
       il caso di Cesare Borgia
"""
demo_title=Text(root,DemoName)
demo_title.SetAlign(CENTER_CENTER)
demo_title.SetPosition(0,300)

title=Text(root,"")
title.SetAlign(CENTER_CENTER)
title.SetPosition(0,430)

viewer.SetRoot(root)    
viewer.SetBackground(Vec(0,0,0.2))
cm.SetPose(CameraPose(0, 0, 80, 1200, 90, 1, 0, 0))
    
#---------------------------------    
def cp():
    print "cp = CameraPose", cm.GetPose().Repr()
    
#---------------------------------    

# 1) --- espressione invece di Valore 0
# 2) --- 

def slide0():
    
    demo_title.Show(True)
    demo_title.SetPosition(0,300)
    pic2.Show(True)
    pic2.SetOpacity(1)
    axes.Show(False)
    title.Show(False)

    cp  = cm.GetPose()
    cp0 = CameraPose(0, 0, 80, 1200, 90, 1, 0, 0)
    cp1 = CameraPose (0, 0, 0, 600, 90, 1, 0, 0)
    
    am.clear()
    Anim(0,1,   cm.SetPose, cp, cp0  )
    Anim(2,1,   demo_title.SetPosition, Vec(0,300,0), Vec(0,700,0)  )
    Anim(2,1,   cm.SetPose, cp0, cp1  )
    
    am.play()
    
def slide1():
    cp  = cm.GetPose()
    cp1 = CameraPose (0, 0, 0, 600, 90, 1, 0, 0)
    cp2 = CameraPose (157.696, -1, 101.499, 207.268, 90, 1, 0, 0)
    
    demo_title.Show(False)
    title.Show(True)
    pic2.Show(True)
    pic3.Show(True)
    axes.Show(False)

    am.clear()
    Anim(0,0.5, title.SetPosition, Vec(0,430,0), Vec(0,500,0)  )
    Call(1,     title.SetText,     "this is slide 1" )
    Anim(1,0.5, title.SetPosition, Vec(0,500,0), Vec(0,430,0)  )
    Anim(0,2,   pic2.SetOpacity, 1, 0.5 )
    Anim(2,5,   pic2.SetOpacity, 0.4, 0 )
    Anim(3,1,   cm.SetPose, cp1, cp2  )
##    Anim(4,2,   fr.SetScale, Vec(0.25,0.0025,0.25,), Vec(0.25,0.25,0.25)  )

    am.play()


##def slide2():
##    cp  = cm.GetPose()
##    cp0 = CameraPose(4.5, 4.5, 4.5, 56, 90, 1, 0, 0)
##    cp1 = CameraPose(0.776125, -30.4387, 0, 22, 90, 1, 0, 0)
##    
##    demo_title.Show(False)
##    title.Show(True)
##    pic2.Show(False)
##    axes.Show(True)
##
##    am.clear()
##    Anim(0,0.5, title.SetPosition, Vec(0,430,0), Vec(0,500,0)  )
##    Call(1,     title.SetText,     "this is slide 1" )
##    Anim(1,0.5, title.SetPosition, Vec(0,500,0), Vec(0,430,0)  )
##    Anim(0,2,   cm.SetPose, cp, cp1  )
##
##    T0 = T
##
##    am.play()


#---------------------------------    
slides = [
  ("Titolo",slide0),
  ("slide1",slide1),
]


